<?php

namespace app\admin\controller;

use think\Controller;
use think\migration\db\Column;
use think\Request;

/**
 * 新闻分类管理
 */
class NewsClass extends Backend
{

    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\NewsClass();
    }

    public function index()
    {
        $params = $this->request->param();
        list($where, $sort, $order, $offset, $limit) = $this->buildparams();
        $where = [];
        if(isset($params['query']) && $params['query'] != ''){
            $where['name'] = ['like', '%'.$params['query'].'%'];
        }
        $list = $this->model
            ->with($this->with ? $this->with : null)
            ->where($where)
            ->order($sort, $order)
            ->paginate($limit);
        $this->assign('list', $list);
        $this->assign('params', $params);
        return $this->fetch();
    }

}
